<?php

//namespace paper\helper;

use JetBrains\PhpStorm\Pure;
use paper\App;
use paper\component\Session;
use paper\Container;
use paper\dao\Db;
use paper\dao\Query;
use paper\http\Request;
use paper\http\response\RedirectResponse;
use paper\view\View2;

//class Paper
//{
//
//    static function container(): Container
//    {
//        return Container::getInstance();
//    }
//
//    static function app(): App
//    {
//        return self::container()->get(App::class);
//    }
//
//    static function db(){
//        return Db::create();
//    }
//}

function db($name = null): Query|Db
{
    $query = Container::getInstance()->get(Db::class);
    if ($name != null)
        return $query->name($name);
    return $query;
}

function app(): App
{
    return Container::getInstance()->get(App::class);
}

function view(): View2
{
    return Container::getInstance()->get(View2::class);
}

function request(): Request
{
    return Container::getInstance()->get(Request::class);
}

function session(): Session
{
    return Container::getInstance()->get(Session::class);
}

#[Pure]
function redirect($url): RedirectResponse
{
    return new RedirectResponse($url);
}